const Koa = require('koa')
const cors = require('@koa/cors')
const app = new Koa()

const dpTalk = require('./routes/dptalk')

app.use(
  cors({
    origin: 'http://localhost:8080', // 明确指定允许的源
    methods: ['GET', 'POST', 'OPTIONS'],
    allowedHeaders: ['Content-Type']
  })
)

app.use(dpTalk.routes())
app.use(dpTalk.allowedMethods())

app.use(async ctx => {
  ctx.body = 'Hello Koa2'
})

app.listen(3333, () => {
  console.log('Koa2 server running at http://localhost:3333')
})

// http://localhost:3333/dpTalk
